
<!DOCTYPE HTML>
<html lang="zh-hans" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>store · 合同管理</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        <meta name="author" content="Gj">
        
        
    
    <link rel="stylesheet" href="../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-chapter-fold/chapter-fold.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-search-pro/search.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-prism/prism-tomorrow.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
        <link rel="stylesheet" href="../styles/website.css">
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="styles.html" />
    
    
    <link rel="prev" href="router.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="输入并搜索" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../">
            
                <a href="../">
            
                    
                    概要
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="../Framework.html">
            
                <a href="../Framework.html">
            
                    
                    架构
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">src目录</li>
        
        
    
        <li class="chapter " data-level="2.1" data-path="api.html">
            
                <a href="api.html">
            
                    
                    api
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2" data-path="assets.html">
            
                <a href="assets.html">
            
                    
                    assets
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.3" data-path="components.html">
            
                <a href="components.html">
            
                    
                    components
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.4" data-path="filters.html">
            
                <a href="filters.html">
            
                    
                    filters
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.5" data-path="mixins.html">
            
                <a href="mixins.html">
            
                    
                    mixins
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.6" data-path="router.html">
            
                <a href="router.html">
            
                    
                    router
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="2.7" data-path="store.html">
            
                <a href="store.html">
            
                    
                    store
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.8" data-path="styles.html">
            
                <a href="styles.html">
            
                    
                    styles
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.9" data-path="utils.html">
            
                <a href="utils.html">
            
                    
                    utils
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.10" data-path="views/">
            
                <a href="views/">
            
                    
                    views
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.10.1" data-path="views/activate.html">
            
                <a href="views/activate.html">
            
                    
                    activate
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.10.2" data-path="views/approvemanage.html">
            
                <a href="views/approvemanage.html">
            
                    
                    approvemanage
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.10.3" data-path="views/sealmanage.html">
            
                <a href="views/sealmanage.html">
            
                    
                    sealmanage
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.10.4" data-path="views/deptmanage.html">
            
                <a href="views/deptmanage.html">
            
                    
                    deptmanage
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.10.5" data-path="views/faildoc.html">
            
                <a href="views/faildoc.html">
            
                    
                    faildoc
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.10.6" data-path="views/files.html">
            
                <a href="views/files.html">
            
                    
                    files
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.10.7" data-path="views/init.html">
            
                <a href="views/init.html">
            
                    
                    init
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.10.8" data-path="views/layout.html">
            
                <a href="views/layout.html">
            
                    
                    layout
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.10.9" data-path="views/login.html">
            
                <a href="views/login.html">
            
                    
                    login
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.10.10" data-path="views/myfiles.html">
            
                <a href="views/myfiles.html">
            
                    
                    myfiles
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.10.11" data-path="views/passmail.html">
            
                <a href="views/passmail.html">
            
                    
                    passmail
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.10.12" data-path="views/redirect.html">
            
                <a href="views/redirect.html">
            
                    
                    redirect
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.10.13" data-path="views/sysmanage.html">
            
                <a href="views/sysmanage.html">
            
                    
                    sysmanage
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.10.14" data-path="views/template.html">
            
                <a href="views/template.html">
            
                    
                    template
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.10.15" data-path="views/updateinfo.html">
            
                <a href="views/updateinfo.html">
            
                    
                    updateinfo
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.10.16" data-path="views/usermanage.html">
            
                <a href="views/usermanage.html">
            
                    
                    usermanage
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="2.11" data-path="config.html">
            
                <a href="config.html">
            
                    
                    配置文件
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.12" data-path="newPage.html">
            
                <a href="newPage.html">
            
                    
                    新建页面
            
                </a>
            

            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            本书使用 GitBook 发布
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href=".." >store</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h3 id="vuex">Vuex</h3>
<blockquote>
<p>&#x5B9E;&#x9645;&#x4E0A;&#x5C31;&#x662F;&#x4E00;&#x4E2A;&#x5168;&#x5C40;&#x7684;&#x6570;&#x636E;&#x5B58;&#x50A8;&#x4ED3;&#x5E93;&#x3002;&#x5177;&#x4F53;&#x7406;&#x89E3;&#x53C2;&#x8003;&#x5B98;&#x65B9;&#x6587;&#x6863;&#x3002;</p>
<p>modules&#x4E0B;/ app.js&#x3001;parameter.js&#x3001;tagsView.js&#x3001;url.js&#x3001;user.js</p>
</blockquote>
<h5 id="modulesuserjs">modules/user.js</h5>
<p>&#x7528;&#x6237;&#x64CD;&#x4F5C;&#x6BD4;&#x5982;&#x767B;&#x5F55;&#xFF0C;&#x9000;&#x51FA;&#xFF0C;&#x83B7;&#x53D6;&#x7528;&#x6237;&#x4FE1;&#x606F;&#xFF0C;&#x90FD;&#x53EF;&#x4EE5;&#x5728;&#x6B64;&#x6587;&#x4EF6;&#x83B7;&#x53D6;&#x4FE1;&#x606F;&#xFF08;&#x901A;&#x8FC7;vuex&#x65B9;&#x5F0F;&#xFF09;</p>
<pre class="language-"><code class="lang-javascript"><span class="token keyword">import</span> <span class="token punctuation">{</span> user_login<span class="token punctuation">,</span> user_info_get<span class="token punctuation">,</span> user_logout <span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">&apos;@/api/user&apos;</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> webSocket <span class="token keyword">from</span> <span class="token string">&quot;@/utils/webSocket&quot;</span><span class="token punctuation">;</span>

<span class="token keyword">const</span> user <span class="token operator">=</span> <span class="token punctuation">{</span>
  state<span class="token operator">:</span> <span class="token punctuation">{</span>
    user<span class="token operator">:</span> <span class="token punctuation">{</span><span class="token punctuation">}</span><span class="token punctuation">,</span>
    token<span class="token operator">:</span> localStorage<span class="token punctuation">.</span><span class="token function">getItem</span><span class="token punctuation">(</span><span class="token string">&quot;token&quot;</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
    name<span class="token operator">:</span> <span class="token keyword">null</span><span class="token punctuation">,</span>
    avatar<span class="token operator">:</span> <span class="token keyword">null</span><span class="token punctuation">,</span>
    isAdmin<span class="token operator">:</span> <span class="token keyword">null</span><span class="token punctuation">,</span>
    ws<span class="token operator">:</span> <span class="token keyword">null</span><span class="token punctuation">,</span>
    version<span class="token operator">:</span> <span class="token keyword">null</span><span class="token punctuation">,</span>
    isTax<span class="token operator">:</span> <span class="token boolean">false</span><span class="token punctuation">,</span> <span class="token comment">//&#x514D;&#x7A0E;&#x5904;&#x7406;&#x62C5;&#x5F53;</span>
    status<span class="token operator">:</span> <span class="token keyword">null</span>
  <span class="token punctuation">}</span><span class="token punctuation">,</span>
  mutations<span class="token operator">:</span> <span class="token punctuation">{</span>
    <span class="token function-variable function">SET_USER</span><span class="token operator">:</span> <span class="token punctuation">(</span><span class="token parameter">state<span class="token punctuation">,</span> user</span><span class="token punctuation">)</span> <span class="token operator">=&gt;</span> <span class="token punctuation">{</span>
      state<span class="token punctuation">.</span>user <span class="token operator">=</span> user
    <span class="token punctuation">}</span><span class="token punctuation">,</span>
    <span class="token function-variable function">SET_NAME</span><span class="token operator">:</span> <span class="token punctuation">(</span><span class="token parameter">state<span class="token punctuation">,</span> name</span><span class="token punctuation">)</span> <span class="token operator">=&gt;</span> <span class="token punctuation">{</span>
      state<span class="token punctuation">.</span>name <span class="token operator">=</span> name
    <span class="token punctuation">}</span><span class="token punctuation">,</span>
    <span class="token function-variable function">SET_AVATAR</span><span class="token operator">:</span> <span class="token punctuation">(</span><span class="token parameter">state<span class="token punctuation">,</span> avatar</span><span class="token punctuation">)</span> <span class="token operator">=&gt;</span> <span class="token punctuation">{</span>
      state<span class="token punctuation">.</span>avatar <span class="token operator">=</span> avatar
    <span class="token punctuation">}</span><span class="token punctuation">,</span>
    <span class="token function-variable function">SET_IS_ADMIN</span><span class="token operator">:</span> <span class="token punctuation">(</span><span class="token parameter">state<span class="token punctuation">,</span> bool</span><span class="token punctuation">)</span> <span class="token operator">=&gt;</span> <span class="token punctuation">{</span>
      state<span class="token punctuation">.</span>isAdmin <span class="token operator">=</span> bool
    <span class="token punctuation">}</span><span class="token punctuation">,</span>
    <span class="token function-variable function">SET_WS</span><span class="token operator">:</span> <span class="token punctuation">(</span><span class="token parameter">state<span class="token punctuation">,</span> ws</span><span class="token punctuation">)</span> <span class="token operator">=&gt;</span> <span class="token punctuation">{</span>
      state<span class="token punctuation">.</span>ws <span class="token operator">=</span> ws<span class="token punctuation">;</span>
    <span class="token punctuation">}</span><span class="token punctuation">,</span>
    <span class="token function-variable function">SET_VERSION</span><span class="token operator">:</span> <span class="token punctuation">(</span><span class="token parameter">state<span class="token punctuation">,</span> v</span><span class="token punctuation">)</span> <span class="token operator">=&gt;</span> <span class="token punctuation">{</span>
      state<span class="token punctuation">.</span>version <span class="token operator">=</span> v
    <span class="token punctuation">}</span><span class="token punctuation">,</span>
    <span class="token function-variable function">SET_IS_TAX</span><span class="token operator">:</span> <span class="token punctuation">(</span><span class="token parameter">state<span class="token punctuation">,</span> bool</span><span class="token punctuation">)</span> <span class="token operator">=&gt;</span> <span class="token punctuation">{</span>
      state<span class="token punctuation">.</span>isTax <span class="token operator">=</span> bool
    <span class="token punctuation">}</span><span class="token punctuation">,</span>
    <span class="token function-variable function">SET_USER_STATUS</span><span class="token operator">:</span> <span class="token punctuation">(</span><span class="token parameter">state<span class="token punctuation">,</span> status</span><span class="token punctuation">)</span> <span class="token operator">=&gt;</span> <span class="token punctuation">{</span>
      state<span class="token punctuation">.</span>status <span class="token operator">=</span> status
    <span class="token punctuation">}</span><span class="token punctuation">,</span>
  <span class="token punctuation">}</span><span class="token punctuation">,</span>
  actions<span class="token operator">:</span> <span class="token punctuation">{</span>
    <span class="token comment">// &#x7528;&#x6237;&#x540D;&#x767B;&#x5F55;</span>
    <span class="token keyword">async</span> <span class="token function">userLogin</span><span class="token punctuation">(</span><span class="token parameter"><span class="token punctuation">{</span> commit <span class="token punctuation">}</span><span class="token punctuation">,</span> userInfo</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
      <span class="token keyword">const</span> <span class="token punctuation">{</span> data <span class="token punctuation">}</span> <span class="token operator">=</span> <span class="token keyword">await</span> <span class="token function">user_login</span><span class="token punctuation">(</span>userInfo<span class="token punctuation">)</span><span class="token punctuation">;</span>
      <span class="token keyword">if</span><span class="token punctuation">(</span>data<span class="token punctuation">.</span>errorCode <span class="token operator">===</span> <span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
        <span class="token keyword">const</span> <span class="token punctuation">{</span> token<span class="token punctuation">,</span> deptName<span class="token punctuation">,</span> status <span class="token punctuation">}</span> <span class="token operator">=</span> data<span class="token punctuation">.</span>data<span class="token punctuation">;</span>
        localStorage<span class="token punctuation">.</span><span class="token function">setItem</span><span class="token punctuation">(</span><span class="token string">&quot;token&quot;</span><span class="token punctuation">,</span> token<span class="token punctuation">)</span><span class="token punctuation">;</span>
        localStorage<span class="token punctuation">.</span><span class="token function">setItem</span><span class="token punctuation">(</span><span class="token string">&quot;deptName&quot;</span><span class="token punctuation">,</span> deptName <span class="token operator">||</span> <span class="token string">&apos;&apos;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token function">commit</span><span class="token punctuation">(</span><span class="token string">&quot;SET_USER_STATUS&quot;</span><span class="token punctuation">,</span> status<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token keyword">return</span> data<span class="token punctuation">.</span>data<span class="token punctuation">;</span>
      <span class="token punctuation">}</span>
    <span class="token punctuation">}</span><span class="token punctuation">,</span>
    <span class="token keyword">async</span> <span class="token function">getUserInfo</span><span class="token punctuation">(</span><span class="token parameter"><span class="token punctuation">{</span> commit<span class="token punctuation">,</span> state <span class="token punctuation">}</span></span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
      <span class="token comment">//&#x4EE3;&#x6FC0;&#x6D3B;&#x72B6;&#x6001;</span>
      <span class="token keyword">if</span><span class="token punctuation">(</span>state<span class="token punctuation">.</span>status <span class="token operator">==</span> <span class="token number">2</span><span class="token punctuation">)</span> <span class="token keyword">return</span><span class="token punctuation">;</span>          
      <span class="token keyword">const</span> <span class="token punctuation">{</span> data <span class="token punctuation">}</span> <span class="token operator">=</span> <span class="token keyword">await</span> <span class="token function">user_info_get</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
      <span class="token keyword">if</span><span class="token punctuation">(</span>data<span class="token punctuation">.</span>errorCode <span class="token operator">===</span> <span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
        <span class="token keyword">const</span> <span class="token punctuation">{</span> isAdmin<span class="token punctuation">,</span> avatar<span class="token punctuation">,</span> name<span class="token punctuation">,</span> version<span class="token punctuation">,</span> roles <span class="token punctuation">}</span> <span class="token operator">=</span> data<span class="token punctuation">.</span>data<span class="token punctuation">;</span>
        <span class="token keyword">if</span><span class="token punctuation">(</span>avatar<span class="token punctuation">)</span><span class="token punctuation">{</span>
          <span class="token keyword">if</span><span class="token punctuation">(</span>state<span class="token punctuation">.</span>ws<span class="token punctuation">)</span> state<span class="token punctuation">.</span>ws<span class="token punctuation">.</span><span class="token function">close</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
          <span class="token function">webSocket</span><span class="token punctuation">(</span>avatar<span class="token punctuation">,</span> <span class="token punctuation">(</span><span class="token parameter"><span class="token punctuation">{</span> data<span class="token operator">:</span> ws_avatar<span class="token punctuation">,</span> ws <span class="token punctuation">}</span></span><span class="token punctuation">)</span> <span class="token operator">=&gt;</span> <span class="token punctuation">{</span>
            <span class="token function">commit</span><span class="token punctuation">(</span><span class="token string">&quot;SET_WS&quot;</span><span class="token punctuation">,</span> ws<span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token function">commit</span><span class="token punctuation">(</span><span class="token string">&quot;SET_AVATAR&quot;</span><span class="token punctuation">,</span> ws_avatar<span class="token operator">?</span> <span class="token string">&apos;data:image/jpeg;base64,&apos;</span> <span class="token operator">+</span> ws_avatar<span class="token operator">:</span> <span class="token string">&apos;&apos;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
          <span class="token punctuation">}</span><span class="token punctuation">,</span> <span class="token parameter">err</span> <span class="token operator">=&gt;</span> <span class="token punctuation">{</span><span class="token punctuation">}</span><span class="token punctuation">)</span>
        <span class="token punctuation">}</span>
        <span class="token function">commit</span><span class="token punctuation">(</span><span class="token string">&quot;SET_VERSION&quot;</span><span class="token punctuation">,</span> version<span class="token punctuation">.</span><span class="token function">toLowerCase</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token function">commit</span><span class="token punctuation">(</span><span class="token string">&quot;SET_NAME&quot;</span><span class="token punctuation">,</span> name<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token function">commit</span><span class="token punctuation">(</span><span class="token string">&quot;SET_IS_ADMIN&quot;</span><span class="token punctuation">,</span> isAdmin<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token function">commit</span><span class="token punctuation">(</span><span class="token string">&quot;SET_USER&quot;</span><span class="token punctuation">,</span> data<span class="token punctuation">.</span>data<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token function">commit</span><span class="token punctuation">(</span><span class="token string">&quot;SET_IS_TAX&quot;</span><span class="token punctuation">,</span> roles<span class="token punctuation">.</span><span class="token function">indexOf</span><span class="token punctuation">(</span><span class="token number">3</span><span class="token punctuation">)</span> <span class="token operator">!=</span> <span class="token operator">-</span><span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
      <span class="token punctuation">}</span>
    <span class="token punctuation">}</span><span class="token punctuation">,</span>
    <span class="token keyword">async</span> <span class="token function">setAvatar</span><span class="token punctuation">(</span><span class="token parameter"><span class="token punctuation">{</span> commit<span class="token punctuation">,</span> state  <span class="token punctuation">}</span><span class="token punctuation">,</span> avatar</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
      <span class="token function">commit</span><span class="token punctuation">(</span><span class="token string">&quot;SET_AVATAR&quot;</span><span class="token punctuation">,</span> avatar<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span><span class="token punctuation">,</span>
    <span class="token comment">// &#x767B;&#x51FA;</span>
    <span class="token keyword">async</span> <span class="token function">userLogOut</span><span class="token punctuation">(</span><span class="token parameter"><span class="token punctuation">{</span> commit<span class="token punctuation">,</span> state <span class="token punctuation">}</span></span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token comment">// localStorage.clear();</span>
        <span class="token keyword">const</span> <span class="token punctuation">{</span> data <span class="token punctuation">}</span> <span class="token operator">=</span> <span class="token keyword">await</span> <span class="token function">user_logout</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token keyword">if</span><span class="token punctuation">(</span>data<span class="token punctuation">.</span>errorCode <span class="token operator">===</span> <span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
          localStorage<span class="token punctuation">.</span><span class="token function">removeItem</span><span class="token punctuation">(</span><span class="token string">&quot;deptName&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
          localStorage<span class="token punctuation">.</span><span class="token function">removeItem</span><span class="token punctuation">(</span><span class="token string">&quot;token&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span>
        <span class="token keyword">if</span><span class="token punctuation">(</span>state<span class="token punctuation">.</span>ws<span class="token punctuation">)</span> state<span class="token punctuation">.</span>ws<span class="token punctuation">.</span><span class="token function">close</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span><span class="token punctuation">,</span>
    <span class="token comment">// &#x524D;&#x7AEF; &#x767B;&#x51FA;</span>
    <span class="token keyword">async</span> <span class="token function">fedLogOut</span><span class="token punctuation">(</span><span class="token parameter"><span class="token punctuation">{</span> commit <span class="token punctuation">}</span></span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
      localStorage<span class="token punctuation">.</span><span class="token function">removeItem</span><span class="token punctuation">(</span><span class="token string">&quot;deptName&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
      localStorage<span class="token punctuation">.</span><span class="token function">removeItem</span><span class="token punctuation">(</span><span class="token string">&quot;token&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
  <span class="token punctuation">}</span>
<span class="token punctuation">}</span>

<span class="token keyword">export</span> <span class="token keyword">default</span> user
</code></pre>
<h5 id="storeappjs">store/app.js</h5>
<p>&#x9879;&#x76EE;&#x7684;&#x4E00;&#x4E9B;&#x516C;&#x7528;&#x529F;&#x80FD;&#xFF0C;&#x65E0;&#x9700;&#x5728;&#x66F4;&#x6539;</p>
<h5 id="storepermissionjs">store/permission.js</h5>
<p>&#x8DEF;&#x7531;&#x6839;&#x636E;&#x6743;&#x9650;&#x751F;&#x6210;&#x3002;</p>
<p>&#x52A8;&#x6001;&#x83DC;&#x5355;&#x6839;&#x636E;&#x65E5;&#x672C;&#x5E74;&#x5EA6;&#x6539;&#x53D8;&#x3002;</p>
<pre class="language-"><code class="lang-javascript"><span class="token keyword">import</span> <span class="token punctuation">{</span> asyncRouterMap<span class="token punctuation">,</span> constantRouterMap <span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">&apos;@/router&apos;</span>
<span class="token keyword">import</span> moment <span class="token keyword">from</span> <span class="token string">&apos;moment&apos;</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> Layout <span class="token keyword">from</span> <span class="token string">&apos;@/views/layout/Layout&apos;</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> user <span class="token keyword">from</span> <span class="token string">&apos;./user&apos;</span>
<span class="token keyword">import</span> i18n <span class="token keyword">from</span> <span class="token string">&apos;@/lang&apos;</span>

<span class="token keyword">function</span> <span class="token function">setMenu</span><span class="token punctuation">(</span><span class="token parameter">title<span class="token punctuation">,</span> path</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
  <span class="token keyword">return</span> <span class="token punctuation">{</span>
    path<span class="token operator">:</span> <span class="token template-string"><span class="token template-punctuation string">`</span><span class="token string">/</span><span class="token interpolation"><span class="token interpolation-punctuation punctuation">${</span>path<span class="token interpolation-punctuation punctuation">}</span></span><span class="token template-punctuation string">`</span></span><span class="token punctuation">,</span>
    component<span class="token operator">:</span> Layout<span class="token punctuation">,</span>
    redirect<span class="token operator">:</span> <span class="token template-string"><span class="token template-punctuation string">`</span><span class="token interpolation"><span class="token interpolation-punctuation punctuation">${</span>path<span class="token interpolation-punctuation punctuation">}</span></span><span class="token template-punctuation string">`</span></span><span class="token punctuation">,</span>
    meta<span class="token operator">:</span> <span class="token punctuation">{</span> title<span class="token operator">:</span> title<span class="token punctuation">,</span> icon<span class="token operator">:</span> <span class="token string">&apos;iconfont ali-wendang&apos;</span> <span class="token punctuation">}</span><span class="token punctuation">,</span>
    children<span class="token operator">:</span> <span class="token punctuation">[</span>
        <span class="token punctuation">{</span>
            path<span class="token operator">:</span> <span class="token template-string"><span class="token template-punctuation string">`</span><span class="token string">/</span><span class="token interpolation"><span class="token interpolation-punctuation punctuation">${</span>path<span class="token interpolation-punctuation punctuation">}</span></span><span class="token template-punctuation string">`</span></span><span class="token punctuation">,</span>
            name<span class="token operator">:</span> <span class="token template-string"><span class="token template-punctuation string">`</span><span class="token interpolation"><span class="token interpolation-punctuation punctuation">${</span>path<span class="token interpolation-punctuation punctuation">}</span></span><span class="token template-punctuation string">`</span></span><span class="token punctuation">,</span>
            <span class="token function-variable function">component</span><span class="token operator">:</span> <span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">=&gt;</span> <span class="token keyword">import</span><span class="token punctuation">(</span><span class="token string">&apos;@/views/files&apos;</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
            meta<span class="token operator">:</span> <span class="token punctuation">{</span> title<span class="token operator">:</span> title<span class="token punctuation">,</span> noCache<span class="token operator">:</span> <span class="token boolean">false</span> <span class="token punctuation">}</span>
        <span class="token punctuation">}</span>
    <span class="token punctuation">]</span>
  <span class="token punctuation">}</span>
<span class="token punctuation">}</span>

<span class="token keyword">function</span> <span class="token function">getSectionMenu</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
  <span class="token keyword">return</span> <span class="token keyword">new</span> <span class="token class-name">Promise</span><span class="token punctuation">(</span> <span class="token parameter">resolve</span> <span class="token operator">=&gt;</span> <span class="token punctuation">{</span>
    <span class="token keyword">let</span> month <span class="token operator">=</span> <span class="token function">moment</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">format</span><span class="token punctuation">(</span><span class="token string">&quot;M&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token keyword">let</span> year <span class="token operator">=</span> <span class="token function">moment</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">year</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token keyword">let</span> list <span class="token operator">=</span> <span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token punctuation">;</span>
    <span class="token keyword">const</span> upDoc   <span class="token operator">=</span> i18n<span class="token punctuation">.</span><span class="token function">t</span><span class="token punctuation">(</span><span class="token string">&quot;route.upStage&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token keyword">const</span> downDoc <span class="token operator">=</span> i18n<span class="token punctuation">.</span><span class="token function">t</span><span class="token punctuation">(</span><span class="token string">&quot;route.downStage&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token keyword">const</span> upDateStart   <span class="token operator">=</span> <span class="token string">&apos;-04-01 00:00:00&apos;</span><span class="token punctuation">;</span><span class="token comment">//&#x4E0A;&#x534A;&#x5E74;&#x533A;&#x95F4;&#x5934;</span>
    <span class="token keyword">const</span> upDateEnd     <span class="token operator">=</span> <span class="token string">&apos;-09-30 23:59:59&apos;</span><span class="token punctuation">;</span><span class="token comment">//&#x4E0A;&#x534A;&#x5E74;&#x533A;&#x95F4;&#x5C3E;</span>
    <span class="token keyword">const</span> downDateStart <span class="token operator">=</span> <span class="token string">&apos;-10-01 00:00:00&apos;</span><span class="token punctuation">;</span><span class="token comment">//&#x4E0B;&#x534A;&#x5E74;&#x533A;&#x95F4;&#x5934;</span>
    <span class="token keyword">const</span> downDateEnd   <span class="token operator">=</span> <span class="token string">&apos;-03-31 23:59:59&apos;</span><span class="token punctuation">;</span><span class="token comment">//&#x4E0B;&#x534A;&#x5E74;&#x533A;&#x95F4;&#x5C3E;</span>
    <span class="token keyword">const</span> beforeDate    <span class="token operator">=</span> <span class="token string">&apos;2000-01-01 00:00:00&apos;</span><span class="token punctuation">;</span>
    <span class="token keyword">let</span> before<span class="token punctuation">;</span>
    <span class="token keyword">let</span> mapMenu <span class="token operator">=</span> <span class="token punctuation">{</span><span class="token punctuation">}</span><span class="token punctuation">;</span>

    <span class="token keyword">if</span><span class="token punctuation">(</span>month <span class="token operator">&gt;=</span> <span class="token number">3</span> <span class="token operator">&amp;&amp;</span> month <span class="token operator">&lt;=</span> <span class="token number">9</span><span class="token punctuation">)</span><span class="token punctuation">{</span><span class="token comment">//&#x4E0A;&#x534A;&#x5E74;</span>
      list <span class="token operator">=</span> <span class="token punctuation">[</span>
        <span class="token punctuation">{</span><span class="token comment">//&#x4E0A;&#x671F;&#x5EA6;</span>
          title<span class="token operator">:</span> year<span class="token operator">+</span> upDoc<span class="token punctuation">,</span>
          path<span class="token operator">:</span> year<span class="token operator">+</span> <span class="token string">&apos;up&apos;</span><span class="token punctuation">,</span>
          params<span class="token operator">:</span> <span class="token punctuation">{</span>startTime<span class="token operator">:</span> year <span class="token operator">+</span> upDateStart<span class="token punctuation">,</span> endTime<span class="token operator">:</span> year <span class="token operator">+</span> upDateEnd<span class="token punctuation">}</span>
        <span class="token punctuation">}</span><span class="token punctuation">,</span>
        <span class="token punctuation">{</span>
          title<span class="token operator">:</span> <span class="token punctuation">(</span>year <span class="token operator">-</span><span class="token number">1</span><span class="token punctuation">)</span><span class="token operator">+</span> downDoc<span class="token punctuation">,</span>
          path<span class="token operator">:</span> <span class="token punctuation">(</span>year <span class="token operator">-</span><span class="token number">1</span><span class="token punctuation">)</span><span class="token operator">+</span> <span class="token string">&apos;down&apos;</span><span class="token punctuation">,</span>
          params<span class="token operator">:</span> <span class="token punctuation">{</span>startTime<span class="token operator">:</span> <span class="token punctuation">(</span>year<span class="token operator">-</span><span class="token number">1</span><span class="token punctuation">)</span> <span class="token operator">+</span> downDateStart<span class="token punctuation">,</span> endTime<span class="token operator">:</span> year <span class="token operator">+</span> downDateEnd<span class="token punctuation">}</span>
        <span class="token punctuation">}</span><span class="token punctuation">,</span>
        <span class="token punctuation">{</span><span class="token comment">//&#x4E0A;&#x671F;&#x5EA6;</span>
          title<span class="token operator">:</span> <span class="token punctuation">(</span>year<span class="token operator">-</span><span class="token number">1</span><span class="token punctuation">)</span> <span class="token operator">+</span> upDoc<span class="token punctuation">,</span>
          path<span class="token operator">:</span> <span class="token punctuation">(</span>year<span class="token operator">-</span><span class="token number">1</span><span class="token punctuation">)</span> <span class="token operator">+</span> <span class="token string">&apos;up&apos;</span><span class="token punctuation">,</span>
          params<span class="token operator">:</span> <span class="token punctuation">{</span>startTime<span class="token operator">:</span> <span class="token punctuation">(</span>year<span class="token operator">-</span><span class="token number">1</span><span class="token punctuation">)</span> <span class="token operator">+</span> upDateStart<span class="token punctuation">,</span> endTime<span class="token operator">:</span> <span class="token punctuation">(</span>year<span class="token operator">-</span><span class="token number">1</span><span class="token punctuation">)</span> <span class="token operator">+</span> upDateEnd<span class="token punctuation">}</span>
        <span class="token punctuation">}</span><span class="token punctuation">,</span>
        <span class="token punctuation">{</span>
          title<span class="token operator">:</span> <span class="token punctuation">(</span>year <span class="token operator">-</span> <span class="token number">2</span><span class="token punctuation">)</span> <span class="token operator">+</span> downDoc<span class="token punctuation">,</span>
          path<span class="token operator">:</span> <span class="token punctuation">(</span>year <span class="token operator">-</span> <span class="token number">2</span><span class="token punctuation">)</span> <span class="token operator">+</span> <span class="token string">&apos;down&apos;</span><span class="token punctuation">,</span>
          params<span class="token operator">:</span> <span class="token punctuation">{</span>startTime<span class="token operator">:</span> <span class="token punctuation">(</span>year<span class="token operator">-</span><span class="token number">2</span><span class="token punctuation">)</span> <span class="token operator">+</span> downDateStart<span class="token punctuation">,</span> endTime<span class="token operator">:</span> <span class="token punctuation">(</span>year<span class="token operator">-</span><span class="token number">1</span><span class="token punctuation">)</span> <span class="token operator">+</span> downDateEnd<span class="token punctuation">}</span>
        <span class="token punctuation">}</span>
      <span class="token punctuation">]</span>
      before <span class="token operator">=</span> <span class="token template-string"><span class="token template-punctuation string">`</span><span class="token interpolation"><span class="token interpolation-punctuation punctuation">${</span>year<span class="token operator">-</span><span class="token number">2</span><span class="token interpolation-punctuation punctuation">}</span></span><span class="token string">-06-30before</span><span class="token template-punctuation string">`</span></span><span class="token punctuation">;</span>
      mapMenu<span class="token punctuation">[</span><span class="token template-string"><span class="token template-punctuation string">`</span><span class="token string">/</span><span class="token interpolation"><span class="token interpolation-punctuation punctuation">${</span>before<span class="token interpolation-punctuation punctuation">}</span></span><span class="token template-punctuation string">`</span></span><span class="token punctuation">]</span> <span class="token operator">=</span> <span class="token punctuation">{</span>startTime<span class="token operator">:</span> beforeDate<span class="token punctuation">,</span> endTime<span class="token operator">:</span> <span class="token punctuation">(</span>year<span class="token operator">-</span><span class="token number">2</span><span class="token punctuation">)</span> <span class="token operator">+</span> upDateEnd<span class="token punctuation">}</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span><span class="token keyword">else</span><span class="token punctuation">{</span><span class="token comment">//&#x4E0B;&#x534A;&#x5E74;</span>
      list <span class="token operator">=</span> <span class="token punctuation">[</span>
        <span class="token punctuation">{</span><span class="token comment">//&#x4E0B;&#x671F;&#x5EA6;</span>
          title<span class="token operator">:</span> year<span class="token operator">+</span> downDoc<span class="token punctuation">,</span>
          path<span class="token operator">:</span> year<span class="token operator">+</span> <span class="token string">&apos;down&apos;</span><span class="token punctuation">,</span>
          params<span class="token operator">:</span> <span class="token punctuation">{</span>startTime<span class="token operator">:</span> year <span class="token operator">+</span> downDateStart<span class="token punctuation">,</span> endTime<span class="token operator">:</span> <span class="token punctuation">(</span>year <span class="token operator">+</span> <span class="token number">1</span><span class="token punctuation">)</span> <span class="token operator">+</span> downDateEnd<span class="token punctuation">}</span>
        <span class="token punctuation">}</span><span class="token punctuation">,</span>
        <span class="token punctuation">{</span>
          title<span class="token operator">:</span> year<span class="token operator">+</span> upDoc<span class="token punctuation">,</span>
          path<span class="token operator">:</span> year<span class="token operator">+</span> <span class="token string">&apos;up&apos;</span><span class="token punctuation">,</span>
          params<span class="token operator">:</span> <span class="token punctuation">{</span>startTime<span class="token operator">:</span> year <span class="token operator">+</span> upDateStart<span class="token punctuation">,</span> endTime<span class="token operator">:</span> year <span class="token operator">+</span> upDateEnd<span class="token punctuation">}</span>
        <span class="token punctuation">}</span><span class="token punctuation">,</span>
        <span class="token punctuation">{</span>
          title<span class="token operator">:</span> <span class="token punctuation">(</span>year <span class="token operator">-</span><span class="token number">1</span><span class="token punctuation">)</span><span class="token operator">+</span> downDoc<span class="token punctuation">,</span>
          path<span class="token operator">:</span> <span class="token punctuation">(</span>year <span class="token operator">-</span><span class="token number">1</span><span class="token punctuation">)</span><span class="token operator">+</span> <span class="token string">&apos;down&apos;</span><span class="token punctuation">,</span>
          params<span class="token operator">:</span> <span class="token punctuation">{</span>startTime<span class="token operator">:</span> <span class="token punctuation">(</span>year<span class="token operator">-</span><span class="token number">1</span><span class="token punctuation">)</span> <span class="token operator">+</span> downDateStart<span class="token punctuation">,</span> endTime<span class="token operator">:</span> year <span class="token operator">+</span> downDateEnd<span class="token punctuation">}</span>
        <span class="token punctuation">}</span><span class="token punctuation">,</span>
        <span class="token punctuation">{</span>
          title<span class="token operator">:</span> <span class="token punctuation">(</span>year<span class="token operator">-</span><span class="token number">1</span><span class="token punctuation">)</span> <span class="token operator">+</span> upDoc<span class="token punctuation">,</span>
          path<span class="token operator">:</span> <span class="token punctuation">(</span>year<span class="token operator">-</span><span class="token number">1</span><span class="token punctuation">)</span> <span class="token operator">+</span> <span class="token string">&apos;up&apos;</span><span class="token punctuation">,</span>
          params<span class="token operator">:</span> <span class="token punctuation">{</span>startTime<span class="token operator">:</span> <span class="token punctuation">(</span>year<span class="token operator">-</span><span class="token number">1</span><span class="token punctuation">)</span> <span class="token operator">+</span> upDateStart<span class="token punctuation">,</span> endTime<span class="token operator">:</span> <span class="token punctuation">(</span>year<span class="token operator">-</span><span class="token number">1</span><span class="token punctuation">)</span> <span class="token operator">+</span> upDateEnd<span class="token punctuation">}</span>
        <span class="token punctuation">}</span>
      <span class="token punctuation">]</span>
      before <span class="token operator">=</span> <span class="token template-string"><span class="token template-punctuation string">`</span><span class="token interpolation"><span class="token interpolation-punctuation punctuation">${</span>year<span class="token operator">-</span><span class="token number">2</span><span class="token interpolation-punctuation punctuation">}</span></span><span class="token string">-12-31before</span><span class="token template-punctuation string">`</span></span><span class="token punctuation">;</span>
      mapMenu<span class="token punctuation">[</span><span class="token template-string"><span class="token template-punctuation string">`</span><span class="token string">/</span><span class="token interpolation"><span class="token interpolation-punctuation punctuation">${</span>before<span class="token interpolation-punctuation punctuation">}</span></span><span class="token template-punctuation string">`</span></span><span class="token punctuation">]</span> <span class="token operator">=</span> <span class="token punctuation">{</span>startTime<span class="token operator">:</span> beforeDate<span class="token punctuation">,</span> endTime<span class="token operator">:</span> <span class="token punctuation">(</span>year<span class="token operator">-</span><span class="token number">1</span><span class="token punctuation">)</span> <span class="token operator">+</span> downDateEnd<span class="token punctuation">}</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
    <span class="token keyword">let</span> asyncMenu <span class="token operator">=</span> list<span class="token punctuation">.</span><span class="token function">map</span><span class="token punctuation">(</span><span class="token parameter">item</span> <span class="token operator">=&gt;</span> <span class="token punctuation">{</span>
      mapMenu<span class="token punctuation">[</span><span class="token template-string"><span class="token template-punctuation string">`</span><span class="token string">/</span><span class="token interpolation"><span class="token interpolation-punctuation punctuation">${</span>item<span class="token punctuation">.</span>path<span class="token interpolation-punctuation punctuation">}</span></span><span class="token template-punctuation string">`</span></span><span class="token punctuation">]</span> <span class="token operator">=</span> item<span class="token punctuation">.</span>params<span class="token punctuation">;</span>
      <span class="token keyword">return</span> <span class="token function">setMenu</span><span class="token punctuation">(</span>item<span class="token punctuation">.</span>title<span class="token punctuation">,</span> item<span class="token punctuation">.</span>path<span class="token punctuation">)</span>
    <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    asyncMenu<span class="token punctuation">.</span><span class="token function">push</span><span class="token punctuation">(</span><span class="token function">setMenu</span><span class="token punctuation">(</span><span class="token string">&apos;earlier&apos;</span><span class="token punctuation">,</span> before<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token function">resolve</span><span class="token punctuation">(</span><span class="token punctuation">{</span>asyncMenu<span class="token punctuation">,</span> mapMenu<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
  <span class="token punctuation">}</span><span class="token punctuation">)</span>
<span class="token punctuation">}</span>

<span class="token keyword">const</span> permission <span class="token operator">=</span> <span class="token punctuation">{</span>
  state<span class="token operator">:</span> <span class="token punctuation">{</span>
    routers<span class="token operator">:</span> constantRouterMap<span class="token punctuation">,</span>
    addRouters<span class="token operator">:</span> <span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token punctuation">,</span>
    routerLoadDone<span class="token operator">:</span> <span class="token boolean">false</span><span class="token punctuation">,</span>
    cacheMenu<span class="token operator">:</span> <span class="token punctuation">{</span><span class="token punctuation">}</span>
  <span class="token punctuation">}</span><span class="token punctuation">,</span>
  mutations<span class="token operator">:</span> <span class="token punctuation">{</span>
    <span class="token function-variable function">SET_ROUTERS</span><span class="token operator">:</span> <span class="token punctuation">(</span><span class="token parameter">state<span class="token punctuation">,</span> routers</span><span class="token punctuation">)</span> <span class="token operator">=&gt;</span> <span class="token punctuation">{</span>
      state<span class="token punctuation">.</span>addRouters <span class="token operator">=</span> routers
      state<span class="token punctuation">.</span>routers <span class="token operator">=</span> constantRouterMap<span class="token punctuation">.</span><span class="token function">concat</span><span class="token punctuation">(</span>routers<span class="token punctuation">)</span>
      state<span class="token punctuation">.</span>routerLoadDone <span class="token operator">=</span> <span class="token boolean">true</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span><span class="token punctuation">,</span>
    <span class="token function-variable function">SET_CACHE_MENU</span><span class="token operator">:</span> <span class="token punctuation">(</span><span class="token parameter">state<span class="token punctuation">,</span> menu</span><span class="token punctuation">)</span> <span class="token operator">=&gt;</span> <span class="token punctuation">{</span>
      state<span class="token punctuation">.</span>cacheMenu <span class="token operator">=</span> menu
    <span class="token punctuation">}</span><span class="token punctuation">,</span>
  <span class="token punctuation">}</span><span class="token punctuation">,</span>
  actions<span class="token operator">:</span> <span class="token punctuation">{</span>
    <span class="token keyword">async</span> <span class="token function">generateRoutes</span><span class="token punctuation">(</span><span class="token parameter"><span class="token punctuation">{</span> commit <span class="token punctuation">}</span></span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
      <span class="token keyword">let</span> <span class="token punctuation">{</span>asyncMenu<span class="token punctuation">,</span> mapMenu<span class="token punctuation">}</span> <span class="token operator">=</span> <span class="token keyword">await</span> <span class="token function">getSectionMenu</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
      <span class="token keyword">let</span> asyncRouter <span class="token operator">=</span> <span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token punctuation">;</span>
      <span class="token keyword">if</span><span class="token punctuation">(</span><span class="token operator">!</span>user<span class="token punctuation">.</span>state<span class="token punctuation">.</span>isAdmin<span class="token punctuation">)</span><span class="token punctuation">{</span>
        asyncRouterMap<span class="token punctuation">.</span><span class="token function">forEach</span><span class="token punctuation">(</span><span class="token parameter">item</span> <span class="token operator">=&gt;</span> <span class="token punctuation">{</span>
          <span class="token keyword">if</span><span class="token punctuation">(</span><span class="token operator">!</span>item<span class="token punctuation">.</span>admin<span class="token punctuation">)</span><span class="token punctuation">{</span>
            asyncRouter<span class="token punctuation">.</span><span class="token function">push</span><span class="token punctuation">(</span>item<span class="token punctuation">)</span>
          <span class="token punctuation">}</span>
        <span class="token punctuation">}</span><span class="token punctuation">)</span>
      <span class="token punctuation">}</span><span class="token keyword">else</span><span class="token punctuation">{</span>
        asyncRouter <span class="token operator">=</span> asyncRouterMap<span class="token punctuation">;</span>
      <span class="token punctuation">}</span>
      <span class="token keyword">let</span> accessedRouters <span class="token operator">=</span> asyncMenu<span class="token punctuation">.</span><span class="token function">concat</span><span class="token punctuation">(</span>asyncRouter<span class="token punctuation">)</span><span class="token punctuation">;</span>
      <span class="token function">commit</span><span class="token punctuation">(</span><span class="token string">&quot;SET_CACHE_MENU&quot;</span><span class="token punctuation">,</span> mapMenu<span class="token punctuation">)</span>
      <span class="token function">commit</span><span class="token punctuation">(</span><span class="token string">&apos;SET_ROUTERS&apos;</span><span class="token punctuation">,</span> accessedRouters<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span><span class="token punctuation">,</span>
  <span class="token punctuation">}</span>
<span class="token punctuation">}</span>

<span class="token keyword">export</span> <span class="token keyword">default</span> permission
</code></pre>
<h5 id="stroeurljs">stroe/url.js</h5>
<p>&#x767B;&#x5F55;&#x8DF3;&#x8F6C;&#x3001;&#x7528;&#x6237;&#x6FC0;&#x6D3B;&#x7B49;&#x529F;&#x80FD;&#x4F7F;&#x7528;&#x6765;url&#x4F20;&#x53C2;&#x5224;&#x65AD;&#x3002;&#x4E3A;&#x4E86;&#x4FBF;&#x4E8E;&#x7BA1;&#x7406;&#xFF0C;&#x5199;&#x5728;vuex&#x91CC;&#x9762;</p>
<pre class="language-"><code class="lang-javascript"><span class="token keyword">const</span> url <span class="token operator">=</span> <span class="token punctuation">{</span>
  state<span class="token operator">:</span> <span class="token punctuation">{</span>
    query<span class="token operator">:</span> <span class="token constant">JSON</span><span class="token punctuation">.</span><span class="token function">parse</span><span class="token punctuation">(</span>localStorage<span class="token punctuation">.</span><span class="token function">getItem</span><span class="token punctuation">(</span><span class="token string">&apos;url_query&apos;</span><span class="token punctuation">)</span><span class="token punctuation">)</span>
  <span class="token punctuation">}</span><span class="token punctuation">,</span>
  mutations<span class="token operator">:</span> <span class="token punctuation">{</span>
    <span class="token function-variable function">SET_QUERY</span><span class="token operator">:</span> <span class="token punctuation">(</span><span class="token parameter">state<span class="token punctuation">,</span> query</span><span class="token punctuation">)</span> <span class="token operator">=&gt;</span> <span class="token punctuation">{</span>
      state<span class="token punctuation">.</span>query <span class="token operator">=</span> query
      localStorage<span class="token punctuation">.</span><span class="token function">setItem</span><span class="token punctuation">(</span><span class="token string">&apos;url_query&apos;</span><span class="token punctuation">,</span> <span class="token constant">JSON</span><span class="token punctuation">.</span><span class="token function">stringify</span><span class="token punctuation">(</span>query<span class="token punctuation">)</span><span class="token punctuation">)</span>
    <span class="token punctuation">}</span>
  <span class="token punctuation">}</span><span class="token punctuation">,</span>
  actions<span class="token operator">:</span> <span class="token punctuation">{</span>
    <span class="token function">setUrlQuery</span><span class="token punctuation">(</span><span class="token parameter"><span class="token punctuation">{</span> commit <span class="token punctuation">}</span><span class="token punctuation">,</span> args</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
      <span class="token function">commit</span><span class="token punctuation">(</span><span class="token string">&apos;SET_QUERY&apos;</span><span class="token punctuation">,</span> args<span class="token punctuation">)</span>
    <span class="token punctuation">}</span><span class="token punctuation">,</span>
    <span class="token function">clearUrlQuery</span><span class="token punctuation">(</span><span class="token parameter"><span class="token punctuation">{</span> commit <span class="token punctuation">}</span></span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
      <span class="token function">commit</span><span class="token punctuation">(</span><span class="token string">&apos;SET_QUERY&apos;</span><span class="token punctuation">,</span> <span class="token punctuation">{</span><span class="token punctuation">}</span><span class="token punctuation">)</span>
    <span class="token punctuation">}</span><span class="token punctuation">,</span>
  <span class="token punctuation">}</span>
<span class="token punctuation">}</span>

<span class="token keyword">export</span> <span class="token keyword">default</span> url
</code></pre>
<h5 id="stroeparameterjs">stroe/parameter.js</h5>
<p>&#x5BF9;&#x4E8E;&#x4E00;&#x4E9B;&#x9875;&#x9762;&#x8DF3;&#x8F6C;&#x4F20;&#x53C2;&#x7684;&#x4F7F;&#x7528;&#x3002; vue&#x4F20;&#x53C2;&#x6709;&#x5F88;&#x591A;&#x4E2D;&#xFF0C;&#x6BD4;&#x5982;&#x7236;&#x5B50;&#x7EC4;&#x4EF6;&#x4F20;&#x53C2;&#x7B49;&#x3002;</p>
<p>&#x8FD8;&#x6709;&#x4E00;&#x4E9B;&#x9690;&#x5F0F;&#x7684;&#x4F20;&#x53C2;&#x65B9;&#x5F0F;&#x3002;&#x53EF;&#x4EE5;&#x7528;&#x6B64;&#x529F;&#x80FD;&#x3002;</p>
<pre class="language-"><code class="lang-javascript">
<span class="token keyword">const</span> parameter <span class="token operator">=</span> <span class="token punctuation">{</span>
  state<span class="token operator">:</span> <span class="token punctuation">{</span>
    params<span class="token operator">:</span> <span class="token punctuation">{</span><span class="token punctuation">}</span><span class="token punctuation">,</span>
    emptyDept<span class="token operator">:</span> <span class="token number">0</span>
  <span class="token punctuation">}</span><span class="token punctuation">,</span>

  mutations<span class="token operator">:</span> <span class="token punctuation">{</span>
    <span class="token function-variable function">SET_PARAMS</span><span class="token operator">:</span> <span class="token punctuation">(</span><span class="token parameter">state<span class="token punctuation">,</span> data</span><span class="token punctuation">)</span> <span class="token operator">=&gt;</span> <span class="token punctuation">{</span>
      state<span class="token punctuation">.</span>params <span class="token operator">=</span> data
    <span class="token punctuation">}</span><span class="token punctuation">,</span>
    <span class="token function-variable function">CLEAR_PARAMS</span><span class="token operator">:</span> <span class="token punctuation">(</span><span class="token parameter">state</span><span class="token punctuation">)</span> <span class="token operator">=&gt;</span> <span class="token punctuation">{</span>
      state<span class="token punctuation">.</span>params <span class="token operator">=</span> <span class="token punctuation">{</span><span class="token punctuation">}</span>
    <span class="token punctuation">}</span><span class="token punctuation">,</span>
    <span class="token function-variable function">SET_EMPTY_DEPT</span><span class="token operator">:</span> <span class="token punctuation">(</span><span class="token parameter">state<span class="token punctuation">,</span> num</span><span class="token punctuation">)</span> <span class="token operator">=&gt;</span> <span class="token punctuation">{</span>
      state<span class="token punctuation">.</span>emptyDept <span class="token operator">=</span> num
    <span class="token punctuation">}</span><span class="token punctuation">,</span>
  <span class="token punctuation">}</span><span class="token punctuation">,</span>

  actions<span class="token operator">:</span> <span class="token punctuation">{</span>
    <span class="token function">setParams</span><span class="token punctuation">(</span><span class="token parameter"><span class="token punctuation">{</span> commit <span class="token punctuation">}</span><span class="token punctuation">,</span> data</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
      <span class="token function">commit</span><span class="token punctuation">(</span><span class="token string">&apos;SET_PARAMS&apos;</span><span class="token punctuation">,</span> data<span class="token punctuation">)</span>
    <span class="token punctuation">}</span><span class="token punctuation">,</span>
    <span class="token function">clearParams</span><span class="token punctuation">(</span><span class="token parameter"><span class="token punctuation">{</span>commit<span class="token punctuation">}</span></span><span class="token punctuation">)</span><span class="token punctuation">{</span>
      <span class="token function">commit</span><span class="token punctuation">(</span><span class="token string">&apos;CLEAR_PARAMS&apos;</span><span class="token punctuation">)</span>
    <span class="token punctuation">}</span><span class="token punctuation">,</span>
    <span class="token function">isEmptyDept</span><span class="token punctuation">(</span><span class="token parameter"><span class="token punctuation">{</span> commit <span class="token punctuation">}</span><span class="token punctuation">,</span> num</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
      <span class="token function">commit</span><span class="token punctuation">(</span><span class="token string">&apos;SET_EMPTY_DEPT&apos;</span><span class="token punctuation">,</span> num<span class="token punctuation">)</span>
    <span class="token punctuation">}</span><span class="token punctuation">,</span>
  <span class="token punctuation">}</span>
<span class="token punctuation">}</span>

<span class="token keyword">export</span> <span class="token keyword">default</span> parameter
</code></pre>
<h5 id="storegettersjs">store/getters.js</h5>
<p>vuex <em>getters</em></p>
<pre class="language-"><code class="lang-javascript"><span class="token keyword">const</span> getters <span class="token operator">=</span> <span class="token punctuation">{</span>
  <span class="token function-variable function">sidebar</span><span class="token operator">:</span> <span class="token parameter">state</span> <span class="token operator">=&gt;</span> state<span class="token punctuation">.</span>app<span class="token punctuation">.</span>sidebar<span class="token punctuation">,</span>
  <span class="token function-variable function">language</span><span class="token operator">:</span> <span class="token parameter">state</span> <span class="token operator">=&gt;</span> state<span class="token punctuation">.</span>app<span class="token punctuation">.</span>language<span class="token punctuation">,</span>
  <span class="token function-variable function">size</span><span class="token operator">:</span> <span class="token parameter">state</span> <span class="token operator">=&gt;</span> state<span class="token punctuation">.</span>app<span class="token punctuation">.</span>size<span class="token punctuation">,</span>
  <span class="token function-variable function">device</span><span class="token operator">:</span> <span class="token parameter">state</span> <span class="token operator">=&gt;</span> state<span class="token punctuation">.</span>app<span class="token punctuation">.</span>device<span class="token punctuation">,</span>
  <span class="token function-variable function">theme</span><span class="token operator">:</span> <span class="token parameter">state</span> <span class="token operator">=&gt;</span> state<span class="token punctuation">.</span>app<span class="token punctuation">.</span>theme<span class="token punctuation">,</span>
  <span class="token function-variable function">visitedViews</span><span class="token operator">:</span> <span class="token parameter">state</span> <span class="token operator">=&gt;</span> state<span class="token punctuation">.</span>tagsView<span class="token punctuation">.</span>visitedViews<span class="token punctuation">,</span>
  <span class="token function-variable function">cachedViews</span><span class="token operator">:</span> <span class="token parameter">state</span> <span class="token operator">=&gt;</span> state<span class="token punctuation">.</span>tagsView<span class="token punctuation">.</span>cachedViews<span class="token punctuation">,</span>
  <span class="token function-variable function">user</span><span class="token operator">:</span> <span class="token parameter">state</span> <span class="token operator">=&gt;</span> state<span class="token punctuation">.</span>user<span class="token punctuation">.</span>user<span class="token punctuation">,</span>
  <span class="token function-variable function">token</span><span class="token operator">:</span> <span class="token parameter">state</span> <span class="token operator">=&gt;</span> state<span class="token punctuation">.</span>user<span class="token punctuation">.</span>token<span class="token punctuation">,</span>
  <span class="token function-variable function">version</span><span class="token operator">:</span> <span class="token parameter">state</span> <span class="token operator">=&gt;</span> state<span class="token punctuation">.</span>user<span class="token punctuation">.</span>version<span class="token punctuation">,</span>
  <span class="token function-variable function">avatar</span><span class="token operator">:</span> <span class="token parameter">state</span> <span class="token operator">=&gt;</span> state<span class="token punctuation">.</span>user<span class="token punctuation">.</span>avatar<span class="token punctuation">,</span>
  <span class="token function-variable function">name</span><span class="token operator">:</span> <span class="token parameter">state</span> <span class="token operator">=&gt;</span> state<span class="token punctuation">.</span>user<span class="token punctuation">.</span>name<span class="token punctuation">,</span>
  <span class="token function-variable function">isTax</span><span class="token operator">:</span> <span class="token parameter">state</span> <span class="token operator">=&gt;</span> state<span class="token punctuation">.</span>user<span class="token punctuation">.</span>isTax<span class="token punctuation">,</span>
  <span class="token function-variable function">isAdmin</span><span class="token operator">:</span> <span class="token parameter">state</span> <span class="token operator">=&gt;</span> state<span class="token punctuation">.</span>user<span class="token punctuation">.</span>isAdmin<span class="token punctuation">,</span>
  <span class="token function-variable function">introduction</span><span class="token operator">:</span> <span class="token parameter">state</span> <span class="token operator">=&gt;</span> state<span class="token punctuation">.</span>user<span class="token punctuation">.</span>introduction<span class="token punctuation">,</span>
  <span class="token function-variable function">setting</span><span class="token operator">:</span> <span class="token parameter">state</span> <span class="token operator">=&gt;</span> state<span class="token punctuation">.</span>user<span class="token punctuation">.</span>setting<span class="token punctuation">,</span>
  <span class="token function-variable function">permission_routers</span><span class="token operator">:</span> <span class="token parameter">state</span> <span class="token operator">=&gt;</span> state<span class="token punctuation">.</span>permission<span class="token punctuation">.</span>routers<span class="token punctuation">,</span>
  <span class="token function-variable function">addRouters</span><span class="token operator">:</span> <span class="token parameter">state</span> <span class="token operator">=&gt;</span> state<span class="token punctuation">.</span>permission<span class="token punctuation">.</span>addRouters<span class="token punctuation">,</span>
  <span class="token function-variable function">routerLoadDone</span><span class="token operator">:</span> <span class="token parameter">state</span> <span class="token operator">=&gt;</span> state<span class="token punctuation">.</span>permission<span class="token punctuation">.</span>routerLoadDone<span class="token punctuation">,</span> <span class="token comment">//router&#x662F;&#x5426;&#x5DF2;&#x7ECF;&#x52A0;&#x8F7D;&#x5B8C;&#x6210;</span>

  <span class="token function-variable function">cacheMenu</span><span class="token operator">:</span> <span class="token parameter">state</span> <span class="token operator">=&gt;</span> state<span class="token punctuation">.</span>permission<span class="token punctuation">.</span>cacheMenu<span class="token punctuation">,</span> <span class="token comment">//&#x52A8;&#x6001;&#x6E32;&#x67D3;&#x7684;&#x83DC;&#x5355;</span>
  <span class="token function-variable function">queryParams</span><span class="token operator">:</span> <span class="token parameter">state</span> <span class="token operator">=&gt;</span> state<span class="token punctuation">.</span>parameter<span class="token punctuation">.</span>params<span class="token punctuation">,</span><span class="token comment">// &#x9875;&#x9762;&#x8DF3;&#x8F6C; &#x643A;&#x5E26;&#x62A5;&#x6587;</span>
  <span class="token function-variable function">emptyDept</span><span class="token operator">:</span> <span class="token parameter">state</span> <span class="token operator">=&gt;</span> state<span class="token punctuation">.</span>parameter<span class="token punctuation">.</span>emptyDept<span class="token punctuation">,</span><span class="token comment">// &#x90E8;&#x95E8;&#x5217;&#x8868;&#x662F;&#x5426;&#x7A7A;</span>

  <span class="token function-variable function">urlQuery</span><span class="token operator">:</span> <span class="token parameter">state</span> <span class="token operator">=&gt;</span> state<span class="token punctuation">.</span>url<span class="token punctuation">.</span>query<span class="token punctuation">,</span> <span class="token comment">//url &#x53C2;&#x6570;</span>
<span class="token punctuation">}</span>
<span class="token keyword">export</span> <span class="token keyword">default</span> getters
</code></pre>
<h5 id="storeindexjs">store/index.js</h5>
<p>modules&#x4E0B;&#x6240;&#x6709;&#x6587;&#x4EF6;&#x81EA;&#x5B9A;&#x89E3;&#x6790;&#x5B9A;&#x4E49;&#x3002; &#x65E0;&#x9700;&#x5728;&#x66F4;&#x6539;</p>
<pre class="language-"><code class="lang-javascript"><span class="token keyword">import</span> Vue <span class="token keyword">from</span> <span class="token string">&apos;vue&apos;</span>
<span class="token keyword">import</span> Vuex <span class="token keyword">from</span> <span class="token string">&apos;vuex&apos;</span>
<span class="token keyword">import</span> getters <span class="token keyword">from</span> <span class="token string">&apos;./getters&apos;</span>

Vue<span class="token punctuation">.</span><span class="token function">use</span><span class="token punctuation">(</span>Vuex<span class="token punctuation">)</span>

<span class="token keyword">const</span> modulesFiles <span class="token operator">=</span> require<span class="token punctuation">.</span><span class="token function">context</span><span class="token punctuation">(</span><span class="token string">&apos;./modules&apos;</span><span class="token punctuation">,</span> <span class="token boolean">true</span><span class="token punctuation">,</span> <span class="token regex">/\.js$/</span><span class="token punctuation">)</span>

<span class="token keyword">const</span> modules <span class="token operator">=</span> modulesFiles<span class="token punctuation">.</span><span class="token function">keys</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">reduce</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token parameter">modules<span class="token punctuation">,</span> modulePath</span><span class="token punctuation">)</span> <span class="token operator">=&gt;</span> <span class="token punctuation">{</span>
  <span class="token keyword">const</span> moduleName <span class="token operator">=</span> modulePath<span class="token punctuation">.</span><span class="token function">replace</span><span class="token punctuation">(</span><span class="token regex">/^\.\/(.*)\.\w+$/</span><span class="token punctuation">,</span> <span class="token string">&apos;$1&apos;</span><span class="token punctuation">)</span>
  <span class="token keyword">const</span> value <span class="token operator">=</span> <span class="token function">modulesFiles</span><span class="token punctuation">(</span>modulePath<span class="token punctuation">)</span>
  modules<span class="token punctuation">[</span>moduleName<span class="token punctuation">]</span> <span class="token operator">=</span> value<span class="token punctuation">.</span>default
  <span class="token keyword">return</span> modules
<span class="token punctuation">}</span><span class="token punctuation">,</span> <span class="token punctuation">{</span><span class="token punctuation">}</span><span class="token punctuation">)</span>

<span class="token keyword">const</span> store <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">Vuex<span class="token punctuation">.</span>Store</span><span class="token punctuation">(</span><span class="token punctuation">{</span>
  modules<span class="token punctuation">,</span>
  getters
<span class="token punctuation">}</span><span class="token punctuation">)</span>

<span class="token keyword">export</span> <span class="token keyword">default</span> store
</code></pre>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="router.html" class="navigation navigation-prev " aria-label="Previous page: router">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="styles.html" class="navigation navigation-next " aria-label="Next page: styles">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"store","level":"2.7","depth":1,"next":{"title":"styles","level":"2.8","depth":1,"path":"src/styles.md","ref":"src/styles.md","articles":[]},"previous":{"title":"router","level":"2.6","depth":1,"path":"src/router.md","ref":"src/router.md","articles":[]},"dir":"ltr"},"config":{"plugins":["chapter-fold","-lunr","-search","search-pro","-highlight","prism"],"styles":{"website":"styles/website.css"},"pluginsConfig":{"prism":{"css":["prismjs/themes/prism-tomorrow.css"]},"chapter-fold":{},"search-pro":{},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"theme":"default","author":"Gj","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"合同管理","language":"zh-hans","gitbook":"3.2.3","description":"合同管理Web端"},"file":{"path":"src/store.md","mtime":"2020-02-24T03:16:58.853Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2020-03-07T04:19:36.591Z"},"basePath":"..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../gitbook/gitbook.js"></script>
    <script src="../gitbook/theme.js"></script>
    
        
        <script src="../gitbook/gitbook-plugin-chapter-fold/chapter-fold.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search-pro/jquery.mark.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search-pro/search.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

